﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "IGraphicsNode.h"

namespace gcmp
{
    enum class GisLayerUnit : int32_t
    {
        LayerUnitM = 0,    //米
        LayerUnitMM = 1        //毫米
    };

    enum class GcmpGisProjectionType : int32_t      //投影
    {
        ProjectionType_EPSG3857 = 0,  //MERCATOR
        ProjectionType_EPSG4326 = 1,  //WGS84
        ProjectionType_EPSG4479 = 2,  //CGCS2000经纬度
        ProjectionType_EPSG4547 = 3  //CGCS2000 3度 114E
    };
    enum class GisLayerType : int32_t //图层类型
    {
        LayerType_Osgb = 0,          //osgb图层
        LayerType_RedirectOsgb =1,   //重定向osgb图层
        LayerType_Wmts =2,           //网络wmts图层                   
        LayerType_LocalTiff = 3      //本地tiff数据图层
    };
    enum class GisTiffDataType : int32_t
    {
        TiffDataType_DOM = 0,        // DOM 数字正射影像
        TiffDataType_DEM = 1,        // DEM 数字高程模型
        TiffDataType_DOMDEM = 2      // 参与融合的dem模型
    };
    class GCMP_GRAPHICS_NODE_INTERFACE_EXPORT IGisLayer  : public IDbObject
    {
        DEFINE_CAST_DERIVED(IGisLayer, IDbObject)
    public:
        virtual ~IGisLayer() {}

        /// \brief  获取图层名称
        /// \return       std::wstring
        virtual std::wstring GetName() const = 0;

        /// \brief 获取图层类型
        /// \return       GisLayerType
        virtual GisLayerType GetType() const = 0;

        /// \brief 是否支持平移
        /// \return       bool
        virtual bool IsSupportTransform() const = 0;

        /// \brief 是否在加载首帧采用异步的方式
        /// \return       bool
        virtual bool FirstFrameIsAsync() const = 0;


        virtual OwnerPtr<IGisLayer> Clone() const =0;
    };
    class GCMP_GRAPHICS_NODE_INTERFACE_EXPORT IGisOsgbLayer : public IGisLayer
    {
        DEFINE_CAST_DERIVED(IGisOsgbLayer, IGisLayer)
    public:
        virtual ~IGisOsgbLayer() {}
        static OwnerPtr<IGisLayer> Create(const std::wstring& path, GisLayerUnit unit = GisLayerUnit::LayerUnitM);
        /// \brief   获取单位
        /// \return       GisLayerUnit
        virtual GisLayerUnit GetUnit() const = 0;

        /// \brief 获取数据的路径
        /// \return       std::wstring
        virtual std::wstring GetPath() const = 0;
    };
    class GCMP_GRAPHICS_NODE_INTERFACE_EXPORT IGisRedirectOsgbLayer : public IGisOsgbLayer
    {
        DEFINE_CAST_DERIVED(IGisRedirectOsgbLayer, IGisOsgbLayer)
    public:
        virtual ~IGisRedirectOsgbLayer() {}
        static OwnerPtr<IGisLayer> Create(const std::wstring& path, const std::wstring& pathRedrect, GisLayerUnit unit = GisLayerUnit::LayerUnitM);
        
        /// \brief 获取重定向数据的路径
        /// \return       std::wstring
        virtual std::wstring GetRedirectPath() const = 0;
    };

    class GCMP_GRAPHICS_NODE_INTERFACE_EXPORT IGisWmtsLayer : public IGisLayer
    {
        DEFINE_CAST_DERIVED(IGisWmtsLayer, IGisLayer)
    public:
        virtual ~IGisWmtsLayer() {}
        static OwnerPtr<IGisLayer> Create(const std::wstring& url, const std::wstring& strToken, bool isTopLeftCornerTypeIsYX, const std::wstring& strDpi);
        
        /// \brief 获取网址
        /// \return       std::wstring
        virtual std::wstring GetUrl() const = 0;

        /// \brief   获取下载数据的口令
        /// \return       std::wstring
        virtual std::wstring GetTokenKey() const = 0;

        /// \brief  获取左上点的坐标是否是yx类型,默认是xy类型
        /// \return       bool 
        virtual bool GetTopLeftCornerTypeIsYX() const = 0;

        /// \brief 
        /// \return       std::wstring
        virtual std::wstring GetDpi() const = 0;

        /// \brief  获取投影类型
        /// \return       GcmpGisProjectionType
        virtual GcmpGisProjectionType GetProjectionType() const = 0;
    };
    class GCMP_GRAPHICS_NODE_INTERFACE_EXPORT IGisLocalTiffLayer : public IGisLayer
    {
        DEFINE_CAST_DERIVED(IGisLocalTiffLayer, IGisLayer)
    public:
        virtual ~IGisLocalTiffLayer() {}
        static OwnerPtr<IGisLayer> Create(const std::wstring& sPath, GisTiffDataType dataType);

        /// \brief 获取路径
        /// \return       std::wstring
        virtual std::wstring GetPath() const = 0;

        /// \brief 获取数据类型
        /// \return       GisTiffDataType
        virtual GisTiffDataType GetDataType() const = 0;
    };
    class GCMP_GRAPHICS_NODE_INTERFACE_EXPORT IGisRenderContext : public IObject
    {
    public:
        virtual ~IGisRenderContext() {}
        virtual Box3d GetLayerBoundingBox(const std::wstring& strLayerName) const = 0;
    };

    /// \brief 倾斜摄影数据图形节点
    class GCMP_GRAPHICS_NODE_INTERFACE_EXPORT IGraphicsGisLayer : public IGraphicsNode
    {
        DEFINE_CAST_DERIVED(IGraphicsGisLayer, IGraphicsNode)

    public:
        /// \brief 析构器
        virtual ~IGraphicsGisLayer();

        virtual void SetGisRenderContext(const IGisRenderContext* pRenderContext) = 0;

        /// \brief 创建工厂方法
        /// \param sPath 文件夹的完整路径，在data目录上一层，例如：D://案例1
        /// \return 创建出来的OwnerPtr<IGraphicsGISTile>
        static OwnerPtr<IGraphicsGisLayer> Create(const IGisLayer* pLayer);

        /// \brief 获取GisLayer对象
        /// \return       const IGisLayer*
        virtual const IGisLayer* GetLayer() const =0;

        /// \brief 获取GisLayer的名称
        /// \return       std::wstring
        virtual std::wstring GetLayerName() const = 0;

        /// \brief 获取变换矩阵
        /// \return 变换矩阵
        virtual Matrix4d GetTransformation() const = 0;
    };
}
